package learning.socket4;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Server {//has been finished
	public static void main(String[] args) {
		ServerSocket ss = null;
		Socket s = null;
		List<Socket> list = new ArrayList<Socket>();
		try {
			ss = new ServerSocket(5200);
			System.out.println("waiting...");// Sever Open
			while (true) {
				s = ss.accept();
				System.out.println("wellcom  "
						+ s.getInetAddress().getHostName());
				list.add(s);// add user`s socket
				new Sent_msg(list, s).start();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}